package com.swt.draw.service.impl;

import com.swt.draw.dao.YjkMapper;
import com.swt.draw.entity.Yjk;
import com.swt.draw.example.YjkExample;
import com.swt.draw.service.YjkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName
 * @Description TODO
 * @Author Administrator
 * @Date 2019/10/27 0027 10:54
 * @Version 1.0
 **/
@Service("yjkService")
public class YjkServiceImpl implements YjkService {
    @Resource
    private YjkMapper yjkMapper;

    @Override
    public List<Yjk> getYjkByDm(String dm) {
        YjkExample example = new YjkExample();
        YjkExample.Criteria criteria = example.createCriteria();
        criteria.andDmEqualTo(dm);
        return yjkMapper.selectByExample(example);
    }

    @Override
    public Integer addYjkSelective(Yjk yjk) {
        Integer row = yjkMapper.insertSelective(yjk);
        return row;
    }

    @Override
    public Integer getMaxId() {
        return yjkMapper.getMaxId();
    }

    @Override
    public Integer updateYjkSelective(Yjk yjk) {
        YjkExample example = new YjkExample();
        YjkExample.Criteria criteria = example.createCriteria();
        criteria.andDmEqualTo(yjk.getDm());
        return yjkMapper.updateByExampleSelective(yjk, example);
    }

    @Override
    public Integer deleteYjkByDm(String[] dm) {
        YjkExample example = new YjkExample();
        YjkExample.Criteria criteria = example.createCriteria();
        criteria.andDmIn(Arrays.asList(dm));
        return yjkMapper.deleteByExample(example);
    }
}
